<?php

/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2018/3/26
 * Time: 19:35
 */
class BaseClass {
	function __construct() {
		print "In BaseClass constructor\n";
	}
}

class SubClass extends BaseClass {
	function __construct() {
		parent::__construct();
		print "In SubClass constructor\n";
	}
}

class OtherSubClass extends BaseClass {
	// inherits BaseClass's constructor
}

// In BaseClass constructor
$obj = new BaseClass();

// In BaseClass constructor
// In SubClass constructor
$obj = new SubClass();

// In BaseClass constructor
$obj = new OtherSubClass();

//////////////////////////////////////////////////////////////
class MyDestructableClass {
	function __construct() {
		print "In constructor\n";
		$this->name = "MyDestructableClass";
	}

	function __destruct() {
		print "Destroying " . $this->name . "\n";
	}
}

$obj = new MyDestructableClass();